uthor: YangYi
#Date: 2025-07-19
#Version: v1
#Content: secAgent


# 功能1：系统信息（
#echo "1. 系统信息:"
#echo "   IP:$(hostname -I | awk '{print $1}')"
GREPNETWORK="eth0\|bond0"
GREPIP="10.145.\|10.9."
# 当前节点IP   
IP="`/sbin/ip a s  | grep -iw $GREPNETWORK | grep -i $GREPIP | awk '{print $2}' | awk -F "/" '{print $1}' | head -1`"
echo "   IP:$IP"

# 功能2：查询本节点进程名为secAgent是否存在
#echo "2. 检查secAgent进程状态:"
if pgrep -x "secAgent" >/dev/null; then
    echo "   状态:secAgent进程存在"
else
    echo "   状态:secAgent进程不存在"
fi

# 功能3：检查nc命令并探测端口连通性
#echo "3. 检查nc命令并测试端口连通性:"
if ! command -v nc &> /dev/null; then
    echo "   错误:nc命令未安装"
else
    target_ip="10.144.16.129"
    ports=(1813 1814 8090 8384)

    for port in "${ports[@]}"; do
        if nc -zv -w 3 "$target_ip" "$port" &> /dev/null; then
            echo "   端口:$port 正常"
        else
            echo "   端口:$port 异常"
        fi
    done
fi

# 功能4：查看/opt/secAgent/conf/version.dat文件版本号
#echo "4. 检查secAgent版本文件:"
version_file="/opt/secAgent/conf/version.dat"
if [ -f "$version_file" ]; then
    version=$(cat "$version_file" | grep version: | awk '{print $NF}')
    echo "   版本:$version"
else
    echo "   版本文件:$version_file 不存在"
fi

